﻿
namespace Tests.UnitTest
{
    using vhtrieuMVVM.DesktopClient.ViewModels;
    using vhtrieuMVVM.Windows;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class CustomerViewModelTests
    {
        [TestMethod]
        public void IsViewModel()
        {
            Assert.IsTrue(typeof(CustomerViewModel).BaseType == typeof(ViewModel));
        }

        [TestMethod]
        public void ValidationErrorWhenCustomerNameExceeds32Characters()
        {
            var viewModel = new CustomerViewModel
            {
                CustomerName = "1234567890 vuhongtrieuvuhongtrieu"
            };

            Assert.IsNotNull(viewModel["CustomerName"]);
        }

        [TestMethod]
        public void ValidationErrorWhenCustomerNameIsNotGreaterThanOrEqualTo2Characters()
        {
            var viewModel = new CustomerViewModel
            {
                CustomerName = "sbs"
            };

            Assert.IsNotNull(viewModel["CustomerName"]);
        }

        [TestMethod]
        public void NoValidationErrorWhenCustomerNameMeetsAllRequirements()
        {
            var viewModel = new CustomerViewModel
            {
                CustomerName = "Vu Hong Trieu"
            };

            Assert.IsNull(viewModel["CustomerName"]);
        }

        [TestMethod]
        public void ValidationErrorWhenCustomerNameIsNotProvided()
        {
            var viewModel = new CustomerViewModel
            {
                CustomerName = null
            };

            Assert.IsNotNull(viewModel["CustomerName"]);
        }
    }
}
